<?php
/**
 * Mail: 11447474@qq.com
 * User: LauEl
 * Date: 17/9/23
 * Time: 21:16
 */

include ('mysql.php');
header('Location:index.html');
$name = $_POST['name'];
$password = $_POST['password'];
if (empty($name) && empty($password)) {
    die('不能为空');
}


$list = "select * from member where name='$name'";
$result = $mysqli->query($list);
$list = array();
while ($arr = mysqli_fetch_assoc($result)) {
    $list[] = $arr;
}
if ($list) {
    die('已经存在该姓名');
}
$time = time();
//上面是接收过来的参数
$sql = "insert into member (name,password,add_time) VALUES ('$name','$password','$time')";//插入数据库
$res = $mysqli->query($sql);//发送数据
//如果成功显示成功 不成功就失败
if ($res) {
    header('Location:list.php');
} else {
    echo '添加失败';
}

?>


